﻿using System.Collections.Generic;
using Bll;
using Commons;
using NUnit.Framework;
using DAL;
using System.Linq.Dynamic;

namespace Entity.Initial.IValue
{
    public class AdmColInit : Ini
    {


        [Test]
        public override void Run1()
        {
            this.Run();
        }

        public override void Run2()
        {
            
        }

        public override void Run3()
        {
            
        }

        public override void Run4()
        {
            
        }

        public override void Run5()
        {
            
        }

        public override void Run6()
        {
            
        }

        public int TheFirClassID = 0;
        public void Run()
        {
            using (var db = new PizzaDataDataContext())
            {
                db.AdmCol.InsertAllOnSubmit(InitialValue);
                db.SubmitChanges();
                TheFirClassID = AdmColService.Instance.Dal.GetFirstEntity(p => p.Name == "我的面板", null).ID;
                foreach (var admCol in InitialValue1)
                {
                    admCol.AdmColID = TheFirClassID;
                }
                db.AdmCol.InsertAllOnSubmit(InitialValue1);
                db.SubmitChanges();
            }
        }
        public List<AdmCol> InitialValue
        {
            get
            {
                return new List<AdmCol>()
                           {
                               //一级
                               new AdmCol()
                                   {
                                       Name = "我的面板",
                                       Url = "#MainPage",
                                       ClassLevel = 1,
                                       OrderBy = 0,
                                       Key =  Randoms.GetRandomChars(12,1)
                                   },
                               new AdmCol()
                                   {
                                       Name = "用户会员",
                                       Url = "#MainPage",
                                       ClassLevel = 1,
                                       OrderBy = 1,
                                       Key =  Randoms.GetRandomChars(12,2)
                                   },
                               new AdmCol()
                                   {
                                       Name = "企业商户",
                                       Url = "#MainPage",
                                       ClassLevel = 1,
                                       OrderBy = 2,
                                       Key =  Randoms.GetRandomChars(12,3)
                                   },
                               new AdmCol()
                                   {
                                       Name = "内容管理",
                                       Url = "#MainPage",
                                       ClassLevel = 1,
                                       OrderBy = 3,
                                       Key =  Randoms.GetRandomChars(12,4)
                                   },
                               new AdmCol()
                                   {
                                       Name = "模块管理",
                                       Url = "#MainPage",
                                       ClassLevel = 1,
                                       OrderBy = 4,
                                       Key =  Randoms.GetRandomChars(12,5)
                                   },
                                   

                                   //其他
                               new AdmCol()
                                   {
                                       Name = "欢迎面板",
                                       Url = "#",
                                       ClassLevel = 0,
                                       SmallClass = "",
                                       AdmColID = 0,
                                       OrderBy = 0,
                                       Key =  "uo3Xv0I0Hktq"
                                   },
                           };
            }
        }


        public List<AdmCol> InitialValue1
        {
            get
            {

                return new List<AdmCol>()
                           {


                               //二级
                               new AdmCol()
                                   {
                                       Name = "后台栏目",
                                       Url = "/adm/AdmCol/Index",
                                       ClassLevel = 2,
                                       SmallClass = "常用操作",
                                       AdmColID = TheFirClassID,
                                       OrderBy = 0,
                                       Key = Randoms.GetRandomChars(12, 6)
                                   },
                               new AdmCol()
                                   {
                                       Name = "人员管理",
                                       Url = "/adm/AdmUser/Index",
                                       ClassLevel = 2,
                                       SmallClass = "常用操作",
                                       AdmColID = TheFirClassID,
                                       OrderBy = 0,
                                       Key = Randoms.GetRandomChars(12, 7)
                                   },
                               new AdmCol()
                                   {
                                       Name = "栏目一",
                                       Url = "/Muban/ajaxhtml1",
                                       ClassLevel = 2,
                                       SmallClass = "操作",
                                       AdmColID = TheFirClassID,
                                       OrderBy = 0,
                                       Key = Randoms.GetRandomChars(12, 8)
                                   },
                               new AdmCol()
                                   {
                                       Name = "栏目二",
                                       Url = "/Muban/ajaxhtml1",
                                       ClassLevel = 2,
                                       SmallClass = "操作",
                                       AdmColID = TheFirClassID,
                                       OrderBy = 0,
                                       Key = Randoms.GetRandomChars(12, 9)
                                   },
                           };
            }
        }

        public override void Clear()
        {
            using (var db=new PizzaDataDataContext())
            {
                db.AdmCol.DeleteBatch(p => true);
            }
        }
    }
}
